package com.mind.core.server;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mind.core.net.model.IConnector;

public  class DataHelper {
	private static final Logger logger = LoggerFactory.getLogger(DataHelper.class);
	private Map<String, IConnector> onLinePlayer=new ConcurrentHashMap<String,IConnector>();
	private Map<String,IConnector>  cachePlayers=new ConcurrentHashMap<String, IConnector>();
 	private static DataHelper dataHelper=new DataHelper();
	public static DataHelper getInstance(){
		return dataHelper;
	}
	public IConnector getOnlinePlayer(String id){
		return this.onLinePlayer.get(id);
	}
	public void addOnlinePlayer(String id,IConnector player){
		onLinePlayer.put(id, player);
	}
	public void removeOnlinePlayer(String id){
		onLinePlayer.remove(id);
	}
	public int getOnlinePlayerSize(){
		return this.onLinePlayer.size();
	}
	public void addCachePlayer(IConnector sender){
		cachePlayers.put(sender.id(), sender);
	}
	public void removeCachePlayer(IConnector sender){
		cachePlayers.remove(sender.id());
	}
	public IConnector getCachePlayer(String id){
		return cachePlayers.get(id);
	}
}
